import React, { Component } from 'react';
import { connect } from 'dva';
import { Form, Button, Input, Icon, message } from 'antd';
import styles from './Login.less';
import request from '@/utils/request';
const FormItem = Form.Item;

@connect(({ login, loading }) => ({
  login,
  submitting: loading.effects['login/login'],//根据 loading.effects 对象判断当前异步加载是否完成
}))
class LoginPage extends Component {
  state = {
    type: 'account',
    autoLogin: true,
    company_name: '',
    company_code: '',
  };

  onTabChange = type => {
    this.setState({ type });
  };
  componentDidMount() {
    const username='watergrpcorp01';
    const password='EE923C2D1241E787';
    const that=this
    message.info('正在登录中...')
    setTimeout(function (){
      that.props.dispatch({
        type: `login/login`,
        payload: {
          username,password
          // company_code:company_code,
          // company_id:values.company_id.key,
        },
        callback: () => {

        },
      });
    },1000)

  }
  handleSubmit = (e) => {
    const { location } = this.props;
    const { pathname } = location;
    const company_code = pathname.split('/')[3];
    console.log('company_code', company_code);
    if(e){
      e.preventDefault();
    }

    this.props.form.validateFields({ force: true },
      (err, values) => {
        console.log('values');
        if (!err) {

        }
      },
    );
  };


  render() {
    const { submitting, form } = this.props;
    const { getFieldDecorator } = form;
    return (
      <div >
      </div>
    );
  }
}

export default Form.create()(LoginPage);
